import {
	getToken,
	setToken,
	removeToken
} from "@/common/auth.js"; //token设置
const store = {
	state: {
		// 用户信息
		// 存储uni.setStorageSync("userinfo",res.data);
		// 设置this.$store.commit("login")
		// 获得this.$store.state.userinfo
		userinfo: {}
	},
	mutations: {

		// 获取用户信息
		login(state) {
			state.userinfo = uni.getStorageSync('userinfo');
		},
		// 删除本地储存
		delStorage(state) {
			state.userinfo = '';
			uni.clearStorage();
		},

		// 设置token
		setToken(state, value) {
			setToken(value);
		},
		// 删除token
		removeToken(state, value) {
			removeToken();
		}
	},
	getters: {
		// 获取token，this.$store.getters.getToken('数据')
		getToken: (state) => (e) => {
			//e是接收的数据
			return getToken();
		}
	},
	actions: {}
};
export default store;